<!DOCTYPE HTML>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<body class="gray-bg">
    
     <div class="container-div">
		<div class="row">
			<div class="col-sm-12 search-collapse">
				<form id="formId">
					<div class="select-list">
						<ul>
							<li>
								商家类型：<select name="businesstypeId" th:with="type=${@dict.selectBusinesstypeList()}">
								<option value="">所有</option>
								<option th:each="dict : ${type}" th:text="${dict.businesstypeName}" th:value="${dict.shangjiatypeId}"></option>
							</select>
							</li>
							<li>
								商家名称：<input type="text" name="businessinfoName"/>
							</li>

							<li>
								商家法人：<input type="text" name="faren"/>
							</li>
							<li>
								商户电话：<input type="text" name="businessTel"/>
							</li>

							<li>
								经营地址：<input type="text" name="businessAdress"/>
							</li>

							<li class="select-time">
								<label>入住时间： </label>
								<input type="text" class="time-input" id="startTime" placeholder="开始时间" name="params[beginTime]"/>
								<span>-</span>
								<input type="text" class="time-input" id="endTime" placeholder="结束时间" name="params[endTime]"/>

							</li>
							<li>
								<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
								<a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
							</li>
						</ul>
					</div>
				</form>
			</div>
			
	        <div class="btn-group-sm hidden-xs" id="toolbar" role="group">
				<a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="system:businessinfo:add">
					<i class="fa fa-plus"></i> 添加
				</a>
				<a class="btn btn-primary btn-edit disabled" onclick="$.operate.edit()" shiro:hasPermission="system:businessinfo:edit">
					<i class="fa fa-edit"></i> 修改
				</a>
				<a class="btn btn-danger btn-del btn-del disabled" onclick="$.operate.removeAll()" shiro:hasPermission="system:businessinfo:remove">
					<i class="fa fa-remove"></i> 删除
				</a>
				<a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="system:businessinfo:export">
						<i class="fa fa-download"></i> 导出
				 </a>
			</div>
			<div class="col-sm-12 select-table table-striped">
				<table id="bootstrap-table" data-mobile-responsive="true"></table>
			</div>
		</div>
	</div>
    <div th:include="include :: footer"></div>
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('system:businessinfo:edit')}]];
        var removeFlag = [[${@permission.hasPermi('system:businessinfo:remove')}]];
		var datas = [[${@dict.getType('sys_normal_disable')}]];

        var prefix = ctx + "system/businessinfo";

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
				exportUrl: prefix + "/export",
                modalName: "商家",
				search: false,
		        showExport: true,
                columns: [{
		            checkbox: true
		        },
				{
					field : 'businessinfoId', 
					title : '商家信息ID',
					visible: false
				},
				{
					field : 'businessinfoName', 
					title : '商家名称',
					sortable: true
				},
				{
					field : 'faren', 
					title : '商家法人',
					sortable: true
				},
				{
					field : 'shangjiatype.businesstypeName',
					title : '商家类型',
					sortable: true
				},
				{
					field : 'businessTel', 
					title : '商户电话',
					sortable: true
				},
				{
					field : 'businessAdress', 
					title : '经营地址',
					sortable: true
				},
				{
					field : 'ruZhuTime', 
					title : '入住时间',
					sortable: true
				},
				{
					field : 'monthTrade', 
					title : '当月交易',
					sortable: true
				},
				{
					field : 'monthRevenue', 
					title : '当月营收',
					sortable: true
				},
				{
					field : 'auditStatus', 
					title : '审核状态',
					align: 'center',
					formatter: function(value, row, index) {
						return $.table.selectDictLabel(datas, value);
					}
				},
				{
					field : 'status', 
					title : '启停状态',
					align: 'center',
					formatter: function (value, row, index) {
						return statusTools2(row);
					}
				},
				{
					field : 'createTime', 
					title : '创建时间',
					sortable: true
				},
				{
					field : 'updateTime', 
					title : '修改时间',
					sortable: true
				},
		        {
		            title: '操作',
		            align: 'center',
		            formatter: function(value, row, index) {
		            	var actions = [];
		            	actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="#" onclick="$.operate.edit(\'' + row.businessinfoId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="#" onclick="$.operate.remove(\'' + row.businessinfoId + '\')"><i class="fa fa-remove"></i>删除</a>');
						return actions.join('');
		            }
		        }]
            };
            $.table.init(options);
        });
		/* 商户状态显示 */
		function statusTools2(row) {
			if (row.status == 1) {
				return '<i class=\"fa fa-toggle-off text-info fa-2x\" onclick="enable(\'' + row.businessinfoId + '\')"></i> ';
			} else {
				return '<i class=\"fa fa-toggle-on text-info fa-2x\" onclick="disable(\'' + row.businessinfoId + '\')"></i> ';
			}
		}
		/* 用户管理-停用 */
		function disable(businessinfoId) {
			$.modal.confirm("确认要停用商家吗？", function() {
				$.operate.post(prefix + "/changeStatus", { "businessinfoId": businessinfoId, "status": 1 });
			})
		}

		/* 用户管理启用 */
		function enable(businessinfoId) {
			$.modal.confirm("确认要启用商家吗？", function() {
				$.operate.post(prefix + "/changeStatus", { "businessinfoId": businessinfoId, "status": 0 });
			})
		}
    </script>

</body>
</html>